<?php

namespace IDock\Insurance\ZMBX\Response;

use IDock\Http\Response;
use IDock\Insurance\ZMBX\Response\AllZMBXResponse;
use IDock\Printer\VehicleActualValuePrinter;

class VehicleActualValueResponse extends AllZMBXResponse
{
    public function printerInit(): Response
    {
        $vehicleActualValuePrinter = new VehicleActualValuePrinter();

        $data = $this->getData();
        if($data['status'] == '0002'){
            $this->setError($data['message']);
            $this->printer = $vehicleActualValuePrinter;
            return  $this;
        }
        $result = $data['result'];
        $vehicleActualValuePrinter->actualValue =  $result['actualValue'] ?? '';
        $vehicleActualValuePrinter->actualRate = $result['sumDepreciationRate'] ?? '';
        $vehicleActualValuePrinter->actualValueMax = $result['fairMarketValueUp'] ?? '';
        $vehicleActualValuePrinter->actualValueMin = $result['fairMarketValueDown'] ?? '';

        $this->printer = $vehicleActualValuePrinter;
        return  $this;
    }
}
